
//冒泡排序

var arr = [3,44,55,33,66,13,24,35]
        //    3 44 33 55 13 24 35 66
        //    3 33 44 13 24 35 55 66 
        //    3 33 13 24 35 44 55 66
        //    3 13 24 33 35 44 55 66
//外部循环执行一次
for(var i = 0;i<=(arr.length-1)-1;i++){
    //内部循环 循环完
    for(var j = 0;j<=(arr.length-1)-1;j++){
        if(arr[j]>arr[j+1]){
            var middle = 0
            middle = arr[j]
            arr[j] = arr[j+1]
            arr[j+1] = middle
        }
    }
}
console.log(arr);



//选择排序
var arr1 = [2,10,9,11,24,35,67,22];

for(var x = 0 ; x<=(arr1.length-1)-1;x++){
    var min = x
    for(var c = x+1;c<=arr1.length-1;c++){
        if(arr1[min]>arr1[c]){
            min = c
        }
    }

    if(min != x){
        var m = 0
        m = arr1[x]
        arr1[x] = arr1[min]
        arr1[min] = m
    }
}
console.log(arr1);
